
/*	
 *  -- ************************************************************
	-- Author		:	PARADOX
	-- Create date	:	18-07-2011
	-- Update date	:	PARADOX
	-- Update By	:   14-03-2012
	-- Description	:	Get And Set Number Format [Version 1.0]
	-- ************************************************************
 */

package com.app.megaprosoft.general;
import java.text.*;
public class Number {
	
	public static int unCommaReturnInt(String StrNumber) {
		String StrNo = "";
		
		for(int i=0;i<StrNumber.length();i++)
			if(StrNumber.charAt(i) != ',')
				StrNo += StrNumber.charAt(i);

		return Integer.valueOf(StrNo).intValue();
	} 
	
	public static float unCommaReturnFloat(String StrNumber) {
		String StrNo = "";
		
		for(int i=0;i<StrNumber.length();i++)
			if(StrNumber.charAt(i) != ',')
				StrNo += StrNumber.charAt(i);

		return Float.valueOf(StrNo).floatValue();
	} 
	
	public static double unCommaReturnDouble(String StrNumber) {
		String StrNo = "";
		
		for(int i=0;i<StrNumber.length();i++)
			if(StrNumber.charAt(i) != ',')
				StrNo += StrNumber.charAt(i);

		return Double.valueOf(StrNo).doubleValue();
	}
	
	public static String unCommaReturnString(String StrNumber) {
		String StrNo = "";
		
		for(int i=0;i<StrNumber.length();i++)
			if(StrNumber.charAt(i) != ',')
				StrNo += StrNumber.charAt(i);

		return StrNo;
	}
	
	public static String addComma(double StrNumber,int IntDigit){
		String StrFormat = "";
		if(IntDigit == 1 )
			StrFormat = "###,##0.0";
		else if(IntDigit == 2 )
			StrFormat = "###,##0.00";
		else if(IntDigit == 3 )
			StrFormat = "###,##0.000";
		else if(IntDigit == 4 )
			StrFormat = "###,##0.0000";
		else if(IntDigit == 5 )
			StrFormat = "###,##0.00000";
		else if(IntDigit == 6 )
			StrFormat = "###,##0.000000";
		else
			StrFormat = "###,##0";
		
		try{
			DecimalFormat df = new DecimalFormat(StrFormat);		
			return df.format(StrNumber).toString();
		}catch(Exception e){
			return "0";
		}
	}
	
	public static String addComma0d(double StrNumber){
		try{
			DecimalFormat df = new DecimalFormat("###,##0");		
			return df.format(StrNumber).toString();
		}catch(Exception e){
			return "0";
		}
	}

	
	
	public static String addComma1d(double StrNumber){
		try{
			DecimalFormat df = new DecimalFormat("###,##0.0");		
			return df.format(StrNumber).toString();
		}catch(Exception e){
			return "0";
		}
	}
	
	public static String addComma2d(double StrNumber){
		try{
			DecimalFormat df = new DecimalFormat("###,##0.00");		
			return df.format(StrNumber).toString();
		}catch(Exception e){
			return "0";
		}
	}
	
	public static String addComma3d(double StrNumber){
		try{
			DecimalFormat df = new DecimalFormat("###,##0.000");		
			return df.format(StrNumber).toString();
		}catch(Exception e){
			return "0";
		}
	}
	
	public static String addComma4d(double StrNumber){
		try{
			DecimalFormat df = new DecimalFormat("###,##0.0000");		
			return df.format(StrNumber).toString();
		}catch(Exception e){
			return "0";
		}
	}
	
	public static String addComma0d(String StrNumber){
		try{
			double DoubleNo = Double.valueOf(StrNumber).doubleValue(); 
			DecimalFormat df = new DecimalFormat("###,##0");		
			return df.format(DoubleNo).toString();
		}catch(Exception e){
			return "0";
		}
	}
	
	public static String addComma1d(String StrNumber){
		try{
			double DoubleNo = Double.valueOf(StrNumber).doubleValue(); 
			DecimalFormat df = new DecimalFormat("###,##0.0");		
			return df.format(DoubleNo).toString();
		}catch(Exception e){
			return "0";
		}
	}
	
	public static String addComma2d(String StrNumber){
		try{
			double DoubleNo = Double.valueOf(StrNumber).doubleValue(); 
			DecimalFormat df = new DecimalFormat("###,##0.00");		
			return df.format(DoubleNo).toString();
		}catch(Exception e){
			return "0";
		}
	}
	
	public static String addComma3d(String StrNumber){
		try{
			double DoubleNo = Double.valueOf(StrNumber).doubleValue(); 
			DecimalFormat df = new DecimalFormat("###,##0.000");		
			return df.format(DoubleNo).toString();
		}catch(Exception e){
			return "0";
		}
	}
	
	public static String addComma4d(String StrNumber){
		try{
			double DoubleNo = Double.valueOf(StrNumber).doubleValue(); 
			DecimalFormat df = new DecimalFormat("###,##0.0000");		
			return df.format(DoubleNo).toString();
		}catch(Exception e){
			return "0";
		}
	}
	
	
}
